#ifndef _KEY_H_
#define _KEY_H_

#include "ec_app_config.h"
#include "sleepram.h"

#define CONFIG_USING_KEY                1
#define CONFIG_KEY_ACTIVE_LOW           1

#if (CONFIG_USING_KEY == 1)
/* --------------------------------Import Interface------------------------ */
#define ACTIVATE_SHORT_PRESS_EVENT()    (event_set_ui_state(EVENT_STATE_UI_KEY_CLICK))
#define ACTIVATE_LOOG_PRESS_EVENT()     (event_set_ui_state(EVENT_STATE_UI_EAR_PAIRING))
#define ACTIVATE_LLOOG_PRESS_EVENT()    (event_set_ui_state(EVENT_STATE_UI_EAR_RESTORE))
/* --------------------------------Configuration parameters------------------ */
/* short & long pressed count in 10ms */
#define CONFIG_KEY_SHORT_PRESS_CNT      (150)
#define CONFIG_KEY_LONG_PRESS_CNT       (300)
#define CONFIG_KEY_LLONG_PRESS_CNT      (800)
/* --------------------------------Definition Statement---------------------- */
#define POWER_MODE_READ                 (SLPRAM_VAL_APP_5)
#define POWER_MODE_WRITE(x)             (SLPRAM_VAL_APP_5 = (x))

#define LOCK_STA_READ                   (SLPRAM_VAL_APP_10)
#define LOCK_STA_WRITE(x)               (SLPRAM_VAL_APP_10 = (x))

#define AUTO_LOCK_CNT_READ              (SLPRAM_VAL_APP_3)
#define AUTO_LOCK_CNT_WRITE(x)          (SLPRAM_VAL_APP_3 = x)

/* --------------------------------External Interface------------------------ */

void key_init(void);
bool get_key_pressed_status(void);
void key_handle_10ms(void);
bool get_power_mode(void);
uint8_t get_level_mode(void);
#else
#define key_init()
#define key_handle_10ms()
#define get_key_pressed_status() (0)

#endif

#endif